Skip to content

feat(Card): Add disabled card and clean up props#6659

Merged
tlabaj merged 9 commits intopatternfly:mainfrom
nicolethoen:non_selectable_card
Dec 6, 2021
Merged

feat(Card): Add disabled card and clean up props#6659
tlabaj merged 9 commits intopatternfly:mainfrom
nicolethoen:non_selectable_card

Conversation

@nicolethoen
Copy link
Copy Markdown
Contributor

What: Closes #6567

@patternfly-build
Copy link
Copy Markdown
Collaborator

patternfly-build commented Nov 30, 2021

Copy link
Copy Markdown
Contributor

@mcoker mcoker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Just one question.

return (
<React.Fragment>
<Card isHoverable>
<Card isSelectable selectableVariant="raised">
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a thought - could we combine these so you don't need separate props? Wondering if isSelectable="raised" could apply the new modifier.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a good thought - I figured that adding the selectableVariant="raised" would mean that to opt into the new styling, they'd just need to add indicate they wanted to using the new prop. And eventually, when raised is the default, then it wont be necessary to specify that.

Copy link
Copy Markdown
Member

@mcarrano mcarrano left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great. Thanks @nicolethoen !

Copy link
Copy Markdown
Contributor

@mcoker mcoker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🥳

Comment on lines +87 to +104
let selectableModifiers = '';
if (isSelectable || isHoverable) {
if (isRaised) {
if (isDisabled) {
selectableModifiers = css((isSelectable || isHoverable) && styles.modifiers.nonSelectableRaised);
} else {
selectableModifiers = css(
(isSelectable || isHoverable) && styles.modifiers.selectableRaised,
(isSelectable || isHoverable) && isSelected && styles.modifiers.selectedRaised
);
}
} else {
selectableModifiers = css(
(isSelectable || isHoverable) && styles.modifiers.selectable,
(isSelectable || isHoverable) && isSelected && styles.modifiers.selected
);
}
}
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like this would be cleaner as a function rather than mutating a let.

Comment on lines +91 to +101
selectableModifiers = css((isSelectable || isHoverable) && styles.modifiers.nonSelectableRaised);
} else {
selectableModifiers = css(
(isSelectable || isHoverable) && styles.modifiers.selectableRaised,
(isSelectable || isHoverable) && isSelected && styles.modifiers.selectedRaised
);
}
} else {
selectableModifiers = css(
(isSelectable || isHoverable) && styles.modifiers.selectable,
(isSelectable || isHoverable) && isSelected && styles.modifiers.selected
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, I don't think the repeated isSelectable || isHoverable conditionals here are needed as they are already nested within an if checking that conditional, so they will always be true. I could be missing something though.

/** @beta Modifies the card to include selected-raised styling */
isSelectedRaised?: boolean;
/** @beta Specifies the selectable styling variant */
selectableVariant?: 'legacy' | 'raised';
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

legacy implies the non raised variant will eventually be deprecated. is that the case @mcarrano?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I figured it means it's not preferred and the 'old but supported' way

Copy link
Copy Markdown
Contributor

@tlabaj tlabaj Dec 2, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok I see my confusion. I thought the selectable variant set the card to selectable. That being said. I think the API is a little confusing. May we can rename the prop tp selectableStylingVariant.
I would also suggest not calling the option legacy. It is not really descriptive.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So I was thinking about this more. Would it make sense to deprecate the isSelectable prop and let the selectableVariant prop not only set the styling, but set it selectable too? I think that would make the API more straight forward. Similar to what @mcoker was suggesting in his comment about combining props.

Copy link
Copy Markdown
Contributor

@kmcfaul kmcfaul Dec 2, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about selectStyle or selectableStyle over using variant, since the function of the select remains the same?
Edit: variant was removed nvm


it('Verify that selectable card can be selected and unselected with keyboard input', () => {
cy.get('#selectableCard').focus();
cy.focused().should('have.class', 'pf-m-selectable');
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So non raised card can no longer be selected or selectable?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

correct - I think it's the same as disabled from my understanding

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think that is the case. We are still applying the style and we have an example for that use case. We should be testing both here.

Copy link
Copy Markdown
Contributor

@tlabaj tlabaj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have a few questions about the logic.

/** Modifies the card to include compact styling. Should not be used with isLarge. */
isCompact?: boolean;
/** Modifies the card to include selectable styling */
isSelectable?: boolean;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so, is this prop deprecated?

Copy link
Copy Markdown
Contributor

@kmcfaul kmcfaul Dec 2, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we going to keep supporting the original plain variation of selectable cards? If not I'd say the next breaking release we update isSelectable to use the raised styling and remove isSelectableRaised (I'm just not sure if that really falls under the "deprecated" flag indication though). If we will keep the original styling I think we should bring back in the enum for the style variations and keep using isSelectable as is.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. I was confused at first. I thought the original variant prop also set the card to be selectable.

isSelectedRaised?: boolean;
/** @beta Specifies the selectable styling variant */
selectableVariant?: 'legacy' | 'raised';
/** @beta Modifies a selectable card to have disabled styling */
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we be more explicit here that disabled only applies to non raised cards since we still support both variations.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As I have it, a disabled selectable card without the raised variant is basically a normal card with no hover/select styles at all. Still valid?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I think only the disabled raised selectable card has any special styling. The flag probably shouldn't apply anything to a non-selectable non-raised card (or alternatively, maybe remove any select related props from non-raised cards?)

@kmcfaul
Copy link
Copy Markdown
Contributor

kmcfaul commented Dec 2, 2021

Code looks good to me the only outstanding question I've got is whether we want to keep supporting the original plain selectable style, as that would impact how we mark isSelectable and whether we want an enum prop or bool prop for the raised styling flag.

@mcarrano

@mcoker
Copy link
Copy Markdown
Contributor

mcoker commented Dec 2, 2021

@kmcfaul I think it would be a breaking change if we didn't support it.

Copy link
Copy Markdown
Contributor

@mcoker mcoker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! A thought about isDisabled - I wonder if we'll introduce a "disabled" card at some point that does something else, and if that might create a naming conflict. I don't know that we would, but figured I would mention it.

id={id}
className={css(
styles.card,
isHoverable && styles.modifiers.hoverable,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mcoker, could someone apply pf-m-hoverable. Without, isSelectable. I think removing support completely would technically be breaking. I think we can deprecate it, but we still need to apply the style.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tlabaj yep, they're separate. While you could use them together, it isn't necessary since isSelected has its own hoverable styles (they're the same as what isHoverable applies). https://github.com/patternfly/patternfly/blob/dc6cf07d69cbb80026dca7fe43dc28704aabea64/src/patternfly/components/Card/card.scss#L26-L27

@mcarrano
Copy link
Copy Markdown
Member

mcarrano commented Dec 3, 2021

Code looks good to me the only outstanding question I've got is whether we want to keep supporting the original plain selectable style, as that would impact how we mark isSelectable and whether we want an enum prop or bool prop for the raised styling flag.

@nicolethoen Yes, we still need to support the old selectable style. We didn't want to force a visual breaking change on products currently using selectable cards.

@tlabaj
Copy link
Copy Markdown
Contributor

tlabaj commented Dec 6, 2021

@mcarrano is the intention that next time we have a breaking change release, the old styles will go away?

@mcarrano
Copy link
Copy Markdown
Member

mcarrano commented Dec 6, 2021

@mcarrano is the intention that next time we have a breaking change release, the old styles will go away?

Yes, most likely.


if (isHoverable) {
// eslint-disable-next-line no-console
console.warn("Card: the 'isHoverable' prop is deprecated. Use isSelectable instead.");
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't thinks this is necessary. We don't do this anywhere else that I can find.

Copy link
Copy Markdown
Contributor

@tlabaj tlabaj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@tlabaj tlabaj merged commit 86f225a into patternfly:main Dec 6, 2021
@patternfly-build
Copy link
Copy Markdown
Collaborator

Your changes have been released in:

  • eslint-plugin-patternfly-react@4.18.0
  • @patternfly/react-catalog-view-extension@4.30.0
  • @patternfly/react-charts@6.32.0
  • @patternfly/react-code-editor@4.20.0
  • @patternfly/react-console@4.30.0
  • @patternfly/react-core@4.179.0
  • @patternfly/react-docs@5.40.0
  • @patternfly/react-icons@4.30.0
  • @patternfly/react-inline-edit-extension@4.24.0
  • demo-app-ts@4.139.0
  • @patternfly/react-integration@4.141.0
  • @patternfly/react-log-viewer@4.24.0
  • @patternfly/react-styles@4.29.0
  • @patternfly/react-table@4.48.0
  • @patternfly/react-tokens@4.31.0
  • @patternfly/react-topology@4.26.0
  • @patternfly/react-virtualized-extension@4.26.0
  • transformer-cjs-imports@4.17.0

Thanks for your contribution! 🎉

@nicolethoen nicolethoen deleted the non_selectable_card branch February 8, 2023 13:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Non-selectable card

7 participants